<?php
(!defined('IN_TOA') || !defined('IN_ADMIN')) && exit('Access Denied!');
/*
	[天生创想] (C)2008-2011 515158 Inc.
	This is NOT a freeware, use is subject to license terms
    URL:http://www.515158.com/
*/


get_config_keytable("config_user_edit");
empty($do) && $do = 'list';
if ($do == 'edit') {
	$id = getGP('id','G','int');
	$user = $db->fetch_one_array("SELECT * FROM ".DB_TABLEPRE."user a,".DB_TABLEPRE."user_view b WHERE a.id=b.uid and a.id = '$id'");
	//$purview = unserialize($usergroup['flag']);
	include_once('template/edit.php');

} elseif ($do == 'save') {
	
	$savetype = getGP('savetype','P');
	$id = getGP('id','P','int');
	$username = getGP('username','P');
	if (getGP('password','P')!=''){
	$password = md5(getGP('password','P'));
	}else{
	$password = getGP('oldpassword','P');
	}
	$departmentid = getGP('departmentid','P');
	$name = getGP('name','P');
	$ischeck = getGP('ischeck','P');
	$positionid = getGP('positionid','P');
	$loginip = getGP('loginip','P');
	$groupid = getGP('groupid','P');
	$user = array(
		'password' => $password,
		'groupid' => $groupid,
		'ischeck' => $ischeck,
		'departmentid' => $departmentid,
		'positionid' => $positionid,
		'loginip' => $loginip
	);
	$user_view = array(
		'name' => $name
	);
	update_db('user',$user, array('id' => $id));
	update_db('user_view',$user_view, array('uid' => $id));
	if($id!='')
	{
   $oalog = array(
		'uid' => $_USER->id,
		'content' => $username.get_inc_log(1).$name.get_inc_log(1).$positionid.get_inc_log(1).$loginip.get_inc_log(1).$ischeck.get_inc_log(1).$id.get_inc_log(1).$udate,
		'title' => '修改用户信息'.$name,
		'startdate' => get_date('Y-m-d H:i:s',PHP_TIME),
		'contentid' => $id,
		'type' => '3'
	);
	insert_db('oalog',$oalog);
	}
	goto_page('admin.php?ac=index&fileurl=user');
	

}
?>